﻿// /------------------------------------------------------------
// | FMTH Implementation File
// | 
// | File Name    : FMSplitter.cpp
// | Created By   : sylvain
// | Creation Date: mardi, juin 28, 2005
// | 
// | Purpose      : generic FM splitter wnd
// |				OnDestroy cleans ressource leaks
//  ------------------------------------------------------------


#include "stdafx.h"
#include "TabSplitterWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// /------------------------------------------------------------
// | FMTHClass
// | 
// | Class Name		: CTabSplitterWnd
// | Inherited from : CSplitterWnd
// | Created By     : sylvain
// | Creation Date  : Monday, September 29, 2003
// | 
// | Purpose        : Creates a non resizeable splitter wnd with thin border 
// | 
//  ------------------------------------------------------------


/////////////////////////////////////////////////////////////////////////////
// CTabSplitterWnd

CTabSplitterWnd::CTabSplitterWnd()
{
}

CTabSplitterWnd::~CTabSplitterWnd()
{
}


BEGIN_MESSAGE_MAP(CTabSplitterWnd, CSplitterWnd)
	//{{AFX_MSG_MAP(CTabSplitterWnd)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTabSplitterWnd message handlers
// /------------------------------------------------------------
// | FMTHMethod
// | 
// | Class  Name: CTabSplitterWnd
// | Method Name: OnDestroy
// | 
// | Return Type: void
// | 
// | Parameters:  None
// | 
// | Purpose: cleanup : destroy window created with CSplitterWnd::CreateView 
// |			Avoids ressource leaks detected with BoundsChecker
//  ------------------------------------------------------------
void	CTabSplitterWnd::OnDestroy()
{
	CFrameWnd* pFrame;
	CView* aView;
	int nPaneCount,nPaneNum,nPaneColCount,nPaneColNum;

	CSplitterWnd::OnDestroy();

	pFrame = GetParentFrame();
	//FMASSERT_FATAL(pFrame);
	if(pFrame)
		pFrame->SetActiveView(NULL);// avoids crash in MFC
	nPaneCount=GetRowCount();
	nPaneColCount=GetColumnCount();

	for(nPaneNum=0;nPaneNum<nPaneCount;nPaneNum++)
	{
		for(nPaneColNum=0;nPaneColNum<nPaneColCount;nPaneColNum++)
		{
			aView=((CView *) GetPane(nPaneNum,nPaneColNum));
			//FMASSERT_FATAL(aView);
			if(aView)
				aView->DestroyWindow();
		}
	}
}
